
import os
import time
from threading import Thread
import threading
import shutil
from dld_ts import hebing

def run(m3u8, mp4name):
    ret = hebing(m3u8, mp4name)
    if ret:
        os.remove(m3u8)
    return ret


path = r"\\192.168.123.1\sda1\3"
num_mp4 = 1

while 1:
    for _m3u8 in os.listdir(path):

        file_path = os.path.join(path, _m3u8)
        while 1:
            mp4_name = os.path.join(r"E:\1\2", "%s.mp4" % num_mp4)
            if not os.path.isfile(mp4_name):
                break
            num_mp4 += 1
        m3u8 = os.path.join(r"E:\1\m3u8", "%s.m3u8" % num_mp4)
        print(mp4_name)
        shutil.copy(file_path, m3u8)
        run(m3u8, mp4_name)
        os.remove(file_path)




